package com.ss.android.browser.base.wrapper.net;

import android.text.TextUtils;
import com.bytedance.retrofit2.Callback;
import com.bytedance.retrofit2.ResponseWrapper;

public abstract class NavigationCallback implements Callback {
    public NavigationCallback() {

    }

    public final void onCacheResponse(ResponseWrapper response) {
        if(response != null) {
            if(response.rawResponse.status >= 200 && response.rawResponse.status < 300 && response.body != null) {
                Object v0 = response.body;
                if(v0 == null) {
                    this.b(new Exception("数据为空"));
                }
                else if(((BaseNetBean)v0).err_no == 0) {
                    try {
                        this.a(((BaseNetBean)v0));
                    }
                    catch(Exception v0_1) {
                        this.b(((Throwable)v0_1));
                    }
                }
                else if(((BaseNetBean)v0).err_no == 1) {
                    String v0_2 = TextUtils.isEmpty(((BaseNetBean)v0).err_tips) ? "服务端错误" : ((BaseNetBean)v0).err_tips;
                    this.b(new Exception(v0_2));
                }
                else {
                    this.b(new Exception("服务端错误"));
                }

                return;
            }

            this.b(new Exception("网络请求失败"));
        }
    }

    public abstract void a(BaseNetBean arg1);

    public final void onErrorResponse(Throwable throwable) {
        this.b(new Exception("网络异常"));
    }

    public abstract void b(Throwable arg1);
}

